/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.rakev.matcher.factory;

import java.util.Collection;
import ru.rakev.matcher.Matcher;
import ru.rakev.matcher.ProducerMatcherAdapter;
import ru.rakev.producer.Producer;

/**
 *
 * @author Rakev
 */
public class ProducerMatcherAdapterFactory {

    private static ProducerMatcherAdapterFactory matcherAdapterFactory = new ProducerMatcherAdapterFactory();

    public static ProducerMatcherAdapterFactory create() {
        return matcherAdapterFactory;
    }

    protected ProducerMatcherAdapterFactory() {
    }

    public <F, T> Matcher<F> create(Producer<F, T> producer, Matcher<T> matcher) {
        return new ProducerMatcherAdapter<>(producer, matcher, false);
    }

    public <F, C extends Collection<E>, E> Matcher<F> createAnyOf(Producer<F, C> producer, Matcher<E> matcher) {
        Matcher<C> collectionMatcher = getMatcherAdapterFactory().anyFromCollection(matcher);
        return create(producer, collectionMatcher);
    }

    private MatcherAdapterFactory getMatcherAdapterFactory() {
        return MatcherAdapterFactory.create();
    }
}
